<template>
	<section>
		<el-col :span="8" class="toolbar">
			<el-form label-width="150px" >
				<el-form-item label="提现最少金额">
					<el-input v-model="deploy.withdrawlRequestMin" placeholder="提现最少金额"></el-input>
				</el-form-item>
				<!--<el-form-item label="提现剩余最低限制">-->
					<!--<el-input v-model="deploy.withdrawlRequestSurplusMin" placeholder="提现剩余最低限制" type="number" min="0"></el-input>-->
				<!--</el-form-item>-->
				<el-form-item label="税后比例">
					<el-input v-model="deploy.withdrawlRequestTax" placeholder="税后比例" style="width: 30%"></el-input>
					<span>%</span>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" size="medium" @click="handleAdd">修改</el-button>
				</el-form-item>
			</el-form>
		</el-col>
	</section>
</template>
<script>
	export default {
	    data(){
	        return{
                deploy:{},
				upload:{}
			}
		},
		created(){
	        this.getList()
		},
	    methods:{
	        getList(){
                this.$axios.get('/withdrawl-request-configs',{},this.global().token).then((res)=>{
                    if (res.status == 200){
						this.deploy = res.data
						if(this.deploy.withdrawlRequestMin){
                            this.deploy.withdrawlRequestMin = parseInt(this.deploy.withdrawlRequestMin)/1000
						}else{
                            this.deploy.withdrawlRequestMin = ''
						}
                    }else{
                        this.$message({message: res.data, type: 'error'});
                    }
                })
			},
            handleAdd(){
	            if (this.deploy.withdrawlRequestMin == '') {
                    this.$message({message: '提现最少金额不能为空', type: 'error'});
                }
				// }else if (this.deploy.withdrawlRequestSurplusMin == ''){
                 //    this.$message({message: '最低限制不能为空', type: 'error'});
				// }
				else if(this.deploy.withdrawlRequestTax == ''){
                    this.$message({message: '税后比例不能为空', type: 'error'});
				}else{
                    this.upload.withdrawlRequestMin = parseInt(this.deploy.withdrawlRequestMin) * 1000
                    // this.upload.withdrawlRequestSurplusMin = parseInt(this.deploy.withdrawlRequestSurplusMin * 1000)
                    this.upload.withdrawlRequestTax = parseInt(this.deploy.withdrawlRequestTax)
                    this.$axios.patch('/withdrawl-request-configs',this.upload,this.global().token).then((res)=>{
                        if (res.status == 200){
                            this.$message({message: '修改成功', type: 'success'});
                            this.getList()
                        }else{
                            this.$message({message: res.data, type: 'error'});
                        }
                    })
				}
			}
		}
	}
</script>
<style scoped lang="stylus">
	.toolbar
		padding-top:30px
	.toolbar .el-form-item
		margin-bottom 30px
</style>